News All Tests
Current file: /home/estudydev/workspace/MSP09/web/news/tests/AbstractEStudyDatabaseTest.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
75.00 %75.00%
75.00% 3 / 4
66.67 %66.67%
66.67% 8 / 12
 
AbstractEStudyDatabaseTest
100.00 %100.00%
100.00% 1 / 1
75.00 %75.00%
75.00% 3 / 4
66.67 %66.67%
66.67% 8 / 12
 public function __construct()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 protected function getConnection()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 3 / 3
 protected function insertIntoDatabase($datasetFilename)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 3 / 3
 protected function assertTableEquals($datasetFilename, $table)
100.00 %100.00%
100.00% 1 / 1
66.67 %66.67%
66.67% 2 / 3


       1                 : <?php                                                                                                                                        
       2                 : /*--------------------------------------------------------------------------+                                                                
       3                 : This file is part of eStudy.                                                                                                                 
       4                 : - Modulgruppe:  eStudy :-)                                                                                                                   
       5                 : - Beschreibung: Erleichtert Datenbanktests                                                                                                   
       6                 : - Version:      0.1, 31/08/09                                                                                                                
       7                 : - Autor(en):    Christoph Thelen <christoph.thelen@mni.fh-giessen.de>                                                                        
       8                 : +---------------------------------------------------------------------------+                                                                
       9                 : This program is free software; you can redistribute it and/or                                                                                
      10                 : modify it under the terms of the GNU General Public License                                                                                  
      11                 : as published by the Free Software Foundation; either version 2                                                                               
      12                 : of the License, or any later version.                                                                                                        
      13                 : +---------------------------------------------------------------------------+                                                                
      14                 : This program is distributed in the hope that it will be useful,                                                                              
      15                 : but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                               
      16                 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                
      17                 : GNU General Public License for more details.                                                                                                 
      18                 : You should have received a copy of the GNU General Public License                                                                            
      19                 : along with this program; if not, write to the Free Software                                                                                  
      20                 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                  
      21                 : +--------------------------------------------------------------------------*/                                                                
      22                 :                                                                                                                                              
      23                 : if (! defined("PATH_TO_ROOT")) define("PATH_TO_ROOT", "../../web");                                                                          
      24                 :                                                                                                                                              
      25                 : require_once "estudy_connect.inc.php";                                                                                                       
      26                 : require_once "ez_sql.inc.php";                                                                                                               
      27                 :                                                                                                                                              
      28                 : require_once "PHPUnit/Extensions/Database/TestCase.php";                                                                                     
      29                 : require_once "PHPUnit/Extensions/Database/DataSet/QueryTable.php";                                                                           
      30                 : require_once "PHPUnit/Extensions/Database/DataSet/DataSetFilter.php";                                                                        
      31                 :                                                                                                                                              
      32                 : abstract class AbstractEStudyDatabaseTest extends PHPUnit_Extensions_Database_TestCase {                                                     
      33                 :                                                                                                                                              
      34                 :     /**                                                                                                                                      
      35                 :      * @var ezdb                                                                                                                             
      36                 :      */                                                                                                                                      
      37                 :     protected $db;                                                                                                                           
      38                 :                                                                                                                                              
      39                 :     public function __construct() {                                                                                                          
      40               0 :         global $db;                                                                                                                          
      41                 :                                                                                                                                              
      42               0 :         $this->db = $db;                                                                                                                     
      43               0 :     }                                                                                                                                        
      44                 :                                                                                                                                              
      45                 :     protected function getConnection() {                                                                                                     
      46              14 :         global $settings;                                                                                                                    
      47                 :                                                                                                                                              
      48              14 :         $pdo = new PDO("mysql:host=" . $settings['dbHost'] . ";dbname=" . $settings['dbName'], $settings['dbUser'], $settings['dbPassword']);
      49              14 :         return $this->createDefaultDBConnection($pdo, "estudytestdb");                                                                       
      50                 :     }                                                                                                                                        
      51                 :                                                                                                                                              
      52                 :     /**                                                                                                                                      
      53                 :      * Speichert das DataSet in der Datenbank ab. Beispiel:                                                                                  
      54                 :      * $this->insertIntoDatabase(dirname(__FILE__) . "/datasets/dataset.xml");                                                               
      55                 :      * @param $datasetFilename Benoetigt den kompletten Pfad zum DataSet                                                                     
      56                 :      * @return void                                                                                                                          
      57                 :      */                                                                                                                                      
      58                 :     protected function insertIntoDatabase($datasetFilename) {                                                                                
      59               4 :         $clean = PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT();                                                              
      60               4 :         $clean->execute($this->getConnection(), $this->createXMLDataSet($datasetFilename));                                                  
      61               4 :     }                                                                                                                                        
      62                 :                                                                                                                                              
      63                 :     /**                                                                                                                                      
      64                 :      * Vergleicht den aktuellen Inhalt der uebergebenen Tabelle mit dem DataSet                                                              
      65                 :      * Beispiel:                                                                                                                             
      66                 :      * $this->assertTableEquals(dirname(__FILE__) . "/datasets/dataset.xml", "tabellenname");                                                
      67                 :      * @param array $datasetFilename Benoetigt den kompletten Pfad zum DataSet                                                               
      68                 :      * @param $table Name der Tabelle                                                                                                        
      69                 :      * @return void                                                                                                                          
      70                 :      */                                                                                                                                      
      71                 :     protected function assertTableEquals($datasetFilename, $table) {                                                                         
      72               5 :         $expected = $this->createXMLDataSet($datasetFilename);                                                                               
      73                 :                                                                                                                                              
      74               5 :         $this->assertDataSetsEqual($expected, $this->getConnection()->createDataSet(array($table)));                                         
      75               0 :     }                                                                                                                                        
      76                 : }                                                                                                                                            

Generated by PHPUnit 3.2.21 and Xdebug 2.0.4 at Sat Nov 7 22:04:08 CET 2009.